<?php

/**
 * Description of BoDownloadAffichette
 *
 * @author mssae-9
 */
class FoDownloadAffichetteCtrl extends jController {
    /*
     * code pour le telechargement de l'affichette
     */
    function index() {
        
        $rep = $this->getResponse('tcpdf');
 
        $rep->outputFileName = 'affichette.pdf';
        $rep->doDownload = true;
        
        $recapAnnonce = null;
        if (isset($_SESSION['SESS_RECAP_ANNONCE'])) {
            $recapAnnonce = unserialize($_SESSION['SESS_RECAP_ANNONCE']);
        

            //recuperation contenu 
            $tpl = new jTpl();
            $data = new stdClass();
            $data->desc = 'voiture desc';
            $data->immat = 'voiture immat';
            $data->km = '10000';
            $data->prix = '25000';
            $data->dom = '0350326';
            $data->port = '0425998';
            $data->bur = '06589134';
            $tpl->assign('data', $data);
            
            $contenu = $tpl->fetch('annonce~downloadAffichette');
            // initialise l'objet tcpdf
            $rep->initPdf();
            $rep->tcpdf->setPrintHeader(false);
            $rep->tcpdf->setDisplayMode("real");
            $rep->tcpdf->AddPage('l');
            $rep->tcpdf->SetTitle('Afichette');
            
            $rep->tcpdf->writeHTML($contenu, true, false, true, false, '');
        }

        return $rep;
    }
}
